<template>
  <div>
    <!-- <el-menu
  :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect" background-color="#001529">
  <el-menu-item >爱宠邦管理系统</el-menu-item>
  <el-menu-item > 
      <router-link :to="{name:'Login'}">登录</router-link>
      <router-link :to="{name:'Reg'}">注册</router-link>
  </el-menu-item>
    </el-menu> -->
    <el-row class="tac">
  <el-col :span="5" style="margin-top:-19px">
    <el-menu
      default-active="1"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      background-color="#001529"
      text-color="#fff"
      active-text-color="#ffd04b">
      <div v-for="(item) in Permissions">
        <div v-if="item.tdescribe==storePermission">
      <el-menu-item index="1">
        <i class="el-icon-house"></i>
        <!-- <span slot="title">门店申请</span> -->
        <router-link :to="{name:'StoreApply'}">门店申请</router-link>
      </el-menu-item>
      </div>
      </div>
      <div v-for="(item) in Permissions">
        <div v-if="item.tdescribe==userPermission">
          <el-menu-item index="2">
            <i class="el-icon-pie-chart"></i>
            <span slot="title">商品管理</span>
          </el-menu-item>
        </div>
      </div>
      <div v-for="(item) in Permissions">
        <div v-if="item.tdescribe==orderPermission">
      <el-submenu index="3">
        <template slot="title">
          <i class="el-icon-user-solid"></i>
          <span>订单管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="1-1">商品订单</el-menu-item>
          <el-menu-item index="1-2">服务订单</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
        </div>
      </div>
      <div v-for="(item) in Permissions">
        <div v-if="item.tdescribe==servicePermission">
      <el-submenu index="4">
        <template slot="title">
          <i class="el-icon-sugar"></i>
          <span>服务管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="2-1">服务管理</el-menu-item>
          <el-menu-item index="2-2">服务添加</el-menu-item>
          <el-menu-item index="2-3">服务修改</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
        </div>
      </div>
      <div v-for="(item) in Permissions">
        <div v-if="item.tdescribe==storePermission">
      <el-submenu index="5">
        <template slot="title">
          <i class="el-icon-office-building"></i>
          <span >门店管理</span>
        </template>
         <el-menu-item-group>
          <el-menu-item index="1-1">门店管理</el-menu-item>
          <el-menu-item index="1-2">查看门店</el-menu-item>
          <el-menu-item index="1-3">修改门店</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
        </div>
      </div>
      <div v-for="(item) in Permissions">
        <div v-if="item.tdescribe==petPermission">
      <el-submenu index="6">
        <template slot="title">
          <i class="el-icon-refrigerator"></i>
          <span>宠物主管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="3-1">宠物主管理</el-menu-item>
          <el-menu-item index="3-2">添加宠物主</el-menu-item>
          <el-menu-item index="3-3">修改宠物主</el-menu-item>
          <el-menu-item index="3-4">宠物信息</el-menu-item>
          <el-menu-item index="3-5">添加宠物</el-menu-item>
          <el-menu-item index="3-6">修改宠物信息</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
        </div>
      </div>
      <div v-for="(item) in Permissions">
        <div v-if="item.tdescribe==usersPermission">
      <el-submenu index="7">
        <template slot="title">
          <i class="el-icon-s-grid"></i>
          <span>用户管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="4-1">用户管理</el-menu-item>
          <el-menu-item index="4-2"><router-link :to="{name:'RoleAssign'}">角色分配</router-link></el-menu-item>
          <el-menu-item index="4-3">添加用户</el-menu-item>
          <el-menu-item index="4-4">修改用户</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
        </div>
      </div>
      <div v-for="(item) in Permissions">
        <div v-if="item.tdescribe==rolePermission">
      <el-submenu index="8">
        <template slot="title">
          <i class="el-icon-s-custom"></i>
          <span>角色管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="5-1">角色管理</el-menu-item>
          <el-menu-item index="5-2">查看角色</el-menu-item>
          <el-menu-item index="5-3">权限分配</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
        </div>
      </div>
      <div v-for="(item) in Permissions">
        <div v-if="item.tdescribe==perPermission">
      <el-menu-item index="9">
        <i class="el-icon-s-management"></i>
        <span slot="title">权限管理</span>
      </el-menu-item>
        </div>
      </div>
      <div v-for="(item) in Permissions">
        <div v-if="item.tdescribe==censusPermission">
      <el-submenu index="10">
        <template slot="title">
          <i class="el-icon-collection"></i>
          <span>统计</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="6-1">销售额统计</el-menu-item>
          <el-menu-item index="6-2">销售额占比</el-menu-item>
          <el-menu-item index="6-3">门店分布</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
        </div>
      </div>
      <el-menu-item index="11">
        <i class="el-icon-phone"></i>
        <span slot="title">意见反馈</span>
      </el-menu-item>
    </el-menu>
  </el-col>
</el-row>
  </div>
</template>

<script>
import Center from './Center.vue';
import Header from './Header'
  export default {
    components:{
      Header,Center
  },
    data() {
    
      return {
        activeIndex: '1',
        Permissions: [],
        userPermission: "商品管理权限",
        storePermission: "门店管理权限",
        orderPermission: "订单管理权限",
        servicePermission: "服务管理权限",
        petPermission: "宠物管理权限",
        usersPermission: "用户管理权限",
        rolePermission: "角色管理权限",
        perPermission: "权限管理权限",
        censusPermission: "统计管理权限",

      };
    },
    methods: {
      handleSelect(key, keyPath) {
        console.log(key, keyPath);
      },
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      test(){
       this.Permissions =  this.$store.state.userStore.permissionList;
       console.log("sb");
       console.log(this.$store.state)
      
      }
    },
    watch: {
    "$store.state.userStore.user":{
      immediate:true,
      handler(){
        this.test();
      }
    }
},
  }
  
</script>

<style>
</style>
</style>